home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / CIncludes / MachineExceptions.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  6.5 KB  |  246 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        MachineExceptions.h
  3.  
  4.      Contains:    Processor Exception Handling Interfaces.
  5.  
  6.      Version:    Technology:    Mac OS 8
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1993-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __MACHINEEXCEPTIONS__
  18. #define __MACHINEEXCEPTIONS__
  19.  
  20. #ifndef __MACTYPES__
  21. #include <MacTypes.h>
  22. #endif
  23.  
  24.  
  25.  
  26. #if PRAGMA_ONCE
  27. #pragma once
  28. #endif
  29.  
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33.  
  34. #if PRAGMA_IMPORT
  35. #pragma import on
  36. #endif
  37.  
  38. #if PRAGMA_STRUCT_ALIGN
  39.     #pragma options align=power
  40. #elif PRAGMA_STRUCT_PACKPUSH
  41.     #pragma pack(push, 2)
  42. #elif PRAGMA_STRUCT_PACK
  43.     #pragma pack(2)
  44. #endif
  45.  
  46. /* Some basic declarations used throughout the kernel */
  47. typedef struct OpaqueAreaID*             AreaID;
  48. #if TARGET_OS_MAC
  49. /* Machine Dependent types for PowerPC: */
  50.  
  51. struct MachineInformationPowerPC {
  52.     UnsignedWide                     CTR;
  53.     UnsignedWide                     LR;
  54.     UnsignedWide                     PC;
  55.     unsigned long                     CR;
  56.     unsigned long                     XER;
  57.     unsigned long                     MSR;
  58.     unsigned long                     MQ;
  59.     unsigned long                     ExceptKind;
  60.     unsigned long                     DSISR;
  61.     UnsignedWide                     DAR;
  62.     UnsignedWide                     Reserved;
  63. };
  64. typedef struct MachineInformationPowerPC MachineInformationPowerPC;
  65.  
  66. struct RegisterInformationPowerPC {
  67.     UnsignedWide                     R0;
  68.     UnsignedWide                     R1;
  69.     UnsignedWide                     R2;
  70.     UnsignedWide                     R3;
  71.     UnsignedWide                     R4;
  72.     UnsignedWide                     R5;
  73.     UnsignedWide                     R6;
  74.     UnsignedWide                     R7;
  75.     UnsignedWide                     R8;
  76.     UnsignedWide                     R9;
  77.     UnsignedWide                     R10;
  78.     UnsignedWide                     R11;
  79.     UnsignedWide                     R12;
  80.     UnsignedWide                     R13;
  81.     UnsignedWide                     R14;
  82.     UnsignedWide                     R15;
  83.     UnsignedWide                     R16;
  84.     UnsignedWide                     R17;
  85.     UnsignedWide                     R18;
  86.     UnsignedWide                     R19;
  87.     UnsignedWide                     R20;
  88.     UnsignedWide                     R21;
  89.     UnsignedWide                     R22;
  90.     UnsignedWide                     R23;
  91.     UnsignedWide                     R24;
  92.     UnsignedWide                     R25;
  93.     UnsignedWide                     R26;
  94.     UnsignedWide                     R27;
  95.     UnsignedWide                     R28;
  96.     UnsignedWide                     R29;
  97.     UnsignedWide                     R30;
  98.     UnsignedWide                     R31;
  99. };
  100. typedef struct RegisterInformationPowerPC RegisterInformationPowerPC;
  101.  
  102. struct FPUInformationPowerPC {
  103.     UnsignedWide                     Registers[32];
  104.     unsigned long                     FPSCR;
  105.     unsigned long                     Reserved;
  106. };
  107. typedef struct FPUInformationPowerPC    FPUInformationPowerPC;
  108.  
  109. union Vector128 {
  110. #ifdef __VEC__
  111.     vector unsigned long            v;
  112. #endif
  113.     unsigned long                     l[4];
  114.     unsigned short                     s[8];
  115.     unsigned char                     c[16];
  116. };
  117. typedef union Vector128                    Vector128;
  118.  
  119. struct VectorInformationPowerPC {
  120.     Vector128                         Registers[32];
  121.     Vector128                         VSCR;
  122.     UInt32                             VRsave;
  123. };
  124. typedef struct VectorInformationPowerPC    VectorInformationPowerPC;
  125. /* Exception related declarations */
  126.  
  127. enum {
  128.     kWriteReference                = 0,
  129.     kReadReference                = 1,
  130.     kFetchReference                = 2,
  131.     writeReference                = kWriteReference,                /* Obsolete name*/
  132.     readReference                = kReadReference,                /* Obsolete name*/
  133.     fetchReference                = kFetchReference                /* Obsolete name*/
  134. };
  135.  
  136.  
  137. typedef unsigned long                     MemoryReferenceKind;
  138.  
  139. struct MemoryExceptionInformation {
  140.     AreaID                             theArea;
  141.     LogicalAddress                     theAddress;
  142.     OSStatus                         theError;
  143.     MemoryReferenceKind             theReference;
  144. };
  145. typedef struct MemoryExceptionInformation MemoryExceptionInformation;
  146.  
  147. enum {
  148.     kUnknownException            = 0,
  149.     kIllegalInstructionException = 1,
  150.     kTrapException                = 2,
  151.     kAccessException            = 3,
  152.     kUnmappedMemoryException    = 4,
  153.     kExcludedMemoryException    = 5,
  154.     kReadOnlyMemoryException    = 6,
  155.     kUnresolvablePageFaultException = 7,
  156.     kPrivilegeViolationException = 8,
  157.     kTraceException                = 9,
  158.     kInstructionBreakpointException = 10,
  159.     kDataBreakpointException    = 11,
  160.     kIntegerException            = 12,
  161.     kFloatingPointException        = 13,
  162.     kStackOverflowException        = 14,
  163.     kTaskTerminationException    = 15,
  164.     kTaskCreationException        = 16
  165. };
  166.  
  167. #if OLDROUTINENAMES
  168.  
  169. enum {
  170.     unknownException            = kUnknownException,            /* Obsolete name*/
  171.     illegalInstructionException    = kIllegalInstructionException,    /* Obsolete name*/
  172.     trapException                = kTrapException,                /* Obsolete name*/
  173.     accessException                = kAccessException,                /* Obsolete name*/
  174.     unmappedMemoryException        = kUnmappedMemoryException,        /* Obsolete name*/
  175.     excludedMemoryException        = kExcludedMemoryException,        /* Obsolete name*/
  176.     readOnlyMemoryException        = kReadOnlyMemoryException,        /* Obsolete name*/
  177.     unresolvablePageFaultException = kUnresolvablePageFaultException, /* Obsolete name*/
  178.     privilegeViolationException    = kPrivilegeViolationException,    /* Obsolete name*/
  179.     traceException                = kTraceException,                /* Obsolete name*/
  180.     instructionBreakpointException = kInstructionBreakpointException, /* Obsolete name*/
  181.     dataBreakpointException        = kDataBreakpointException,        /* Obsolete name*/
  182.     integerException            = kIntegerException,            /* Obsolete name*/
  183.     floatingPointException        = kFloatingPointException,        /* Obsolete name*/
  184.     stackOverflowException        = kStackOverflowException,        /* Obsolete name*/
  185.     terminationException        = kTaskTerminationException,    /* Obsolete name*/
  186.     kTerminationException        = kTaskTerminationException        /* Obsolete name*/
  187. };
  188.  
  189. #endif  /* OLDROUTINENAMES */
  190.  
  191.  
  192. typedef unsigned long                     ExceptionKind;
  193.  
  194. union ExceptionInfo {
  195.     MemoryExceptionInformation *    memoryInfo;
  196. };
  197. typedef union ExceptionInfo                ExceptionInfo;
  198.  
  199. struct ExceptionInformationPowerPC {
  200.     ExceptionKind                     theKind;
  201.     MachineInformationPowerPC *        machineState;
  202.     RegisterInformationPowerPC *    registerImage;
  203.     FPUInformationPowerPC *            FPUImage;
  204.     ExceptionInfo                     info;
  205.     VectorInformationPowerPC *        vectorImage;
  206. };
  207. typedef struct ExceptionInformationPowerPC ExceptionInformationPowerPC;
  208.  
  209. typedef ExceptionInformationPowerPC     ExceptionInformation;
  210. typedef MachineInformationPowerPC         MachineInformation;
  211. typedef RegisterInformationPowerPC         RegisterInformation;
  212. typedef FPUInformationPowerPC             FPUInformation;
  213. typedef VectorInformationPowerPC         VectorInformation;
  214. /* 
  215.     Note:    An ExceptionHandler is NOT a UniversalProcPtr.
  216.             It must be a PowerPC function pointer with NO routine descriptor. 
  217. */
  218. typedef CALLBACK_API_C( OSStatus , ExceptionHandler )(ExceptionInformationPowerPC *theException);
  219. /* Routine for installing per-process exception handlers */
  220. EXTERN_API( ExceptionHandler ) InstallExceptionHandler(ExceptionHandler theHandler);
  221.  
  222. #endif  /* TARGET_OS_MAC */
  223.  
  224.  
  225.  
  226. #if PRAGMA_STRUCT_ALIGN
  227.     #pragma options align=reset
  228. #elif PRAGMA_STRUCT_PACKPUSH
  229.     #pragma pack(pop)
  230. #elif PRAGMA_STRUCT_PACK
  231.     #pragma pack()
  232. #endif
  233.  
  234. #ifdef PRAGMA_IMPORT_OFF
  235. #pragma import off
  236. #elif PRAGMA_IMPORT
  237. #pragma import reset
  238. #endif
  239.  
  240. #ifdef __cplusplus
  241. }
  242. #endif
  243.  
  244. #endif /* __MACHINEEXCEPTIONS__ */
  245.  
  246.